package com.jason.designpattern.singleton;

/**
 * @description: 双检锁/双重校验锁（DCL，即 double-checked locking）
 * 优点：实现了懒加载；线程安全；高性能
 * @author: jason.jia
 * @create: 2019-03-08 17:08
 **/
public class DCLSingleton {

    private volatile static DCLSingleton instance;

    private DCLSingleton(){}

    public static DCLSingleton getInstance(){
        if(instance == null){
            synchronized (DCLSingleton.class){
                if(instance == null){
                    instance = new DCLSingleton();
                }
            }
        }
        return instance;
    }
}
